<%@ page import="com.unit10.service.EmpService" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.unit10.service.EmpService" %>
<%@ page import="com.unit10.pojo.Emp" %>
<%@ page import="java.sql.Date" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Insert title here</title>
</head>
<body>
    <%
        EmpService es=new EmpService();
        String name=request.getParameter("name");
        int age=Integer.parseInt(request.getParameter("age"));//getParameter默认获得的是字符串,需要转换成int类型
        String job=request.getParameter("job");
        String deptName=request.getParameter("deptName");
        double salary=Double.parseDouble(request.getParameter("salary"));
        Date hireDate=Date.valueOf(request.getParameter("hireDate"));//字符串转sql中的日期类型

        Emp emp=new Emp();
        emp.setName(name);
        emp.setAge(age);
        emp.setJob(job);
        emp.setDeptName(deptName);
        emp.setSalary(salary);
        emp.setHireDate(hireDate);

        es.addEmp(emp);

        out.print("<h1>添加成功</h1>");
        out.print("<a href='http://127.0.0.1:8080/unit10_war_exploded/emp_index.jsp'>点击跳转到首页</a>");
    %>
</body>
</html>